/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-26 14:54:54
 * @LastEditTime : 2023-06-26 10:56:33
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\EngineeringList.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'

export const EngineeringList = async ({ url, OptionsEvent, Permission }) => {
    let data = {
        type: '形象进度',
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === '490f8d4d-02c6-43c4-b90b-7a5f64525996') !== -1 && (
                <AddDataButton
                    OptionsEvent={OptionsEvent}
                    url={url}
                    type="primary"
                    icon="add"
                    title="新增形象进度清单"
                />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'groupId',
                title: '组号',
                valueType: 'select',
                valueEnum: BuiltInData.engineeringGroupId,
                rules: true,
                hideInSearch: true,
                width: 150,
            },
            { ...commonTableList.code, rules: true },
            commonTableList.tableName,
            {
                dataIndex: 'amount',
                title: '工程量',
                valueType: 'inputNumber',
                rules: true,
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'unit',
                title: '单位',
                valueType: 'input',
                rules: true,
                hideInSearch: true,
                width: 100,
            },
            // 通用部分
            {
                dataIndex: 'sortId',
                title: '排序',
                valueType: 'inputNumber',
                rules: true,
                hideInSearch: true,
                width: 100,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === 'aa1f2a4a-beec-4da2-943f-9dd4f019f111') !== -1 && (
                            <ModDataButton
                                OptionsEvent={OptionsEvent}
                                key="modify"
                                title="修改"
                                url={url}
                                data={record}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '6c87d414-6be5-4ef5-8879-892e624d3b0f') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="delete"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
